package com.mzy.redis.controller;

import com.mzy.redis.service.PhoneService;
import com.mzy.redis.service.impl.PhoneServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


@RestController
@Api(tags = "号码接口")
@RequestMapping("/phone")
public class PhoneController {

    @Resource
    private PhoneService phoneService;

    @GetMapping("/code")
    @ApiOperation("获取手机验证码")
    public String getCode(String phone) {
        return phoneService.getCode(phone);
    }

    @PostMapping("/register")
    @ApiOperation("注册")
    public String register(@RequestBody Map<String, String> map) {
        String phone = map.get("phone");
        String code = map.get("code");
        Boolean isSuccess= phoneService.register(phone, code);
        return isSuccess.toString();
    }
}
